﻿using System;
using UnityEngine;
using UnityEngine.EventSystems;

/// <summary>
/// UI触摸事件扩展，用于自定义事件
/// </summary>
class TouchEx : MonoBehaviour , IDragHandler, IBeginDragHandler, IEndDragHandler, IPointerDownHandler, IPointerUpHandler
{
    public delegate void OnDragDelegate(PointerEventData eventData);
    public OnDragDelegate OnDragCallback = null;
    
    public OnDragDelegate OnBeginDragCallback = null;
    
    public OnDragDelegate OnEndDragCallback = null;

    public OnDragDelegate OnPointerDownCallback = null;

    public OnDragDelegate OnPointerUpCallback = null;
    public void OnDrag(PointerEventData eventData)
    {
        if (OnDragCallback != null) OnDragCallback(eventData);
    }

    public void OnBeginDrag(PointerEventData eventData)
    {
        if (OnBeginDragCallback != null) OnBeginDragCallback(eventData);
    }

    public void OnEndDrag(PointerEventData eventData)
    {
        if (OnEndDragCallback != null) OnEndDragCallback(eventData);
    }

    public void OnPointerDown(PointerEventData eventData)
    {
        if (OnPointerDownCallback != null) OnPointerDownCallback(eventData);
    }

    public void OnPointerUp(PointerEventData eventData)
    {
        if (OnPointerUpCallback != null) OnPointerUpCallback(eventData);
    }
}
